package com.bwjf.dzfp.common.util;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Properties;

/**
 * @author : LiNing
 * @date : Jul 12, 2013 2:33:14 PM
 * @describe :
 * @version ：
 */
public class PropertiesLoad {
	private static String kprUTF8;

	public static void main(String[] args) {
		PropertiesLoad.getProperties();
	}

	public static Properties getProperties() {
		Properties prop = new Properties();
		try {
			prop.load(PropertiesLoad.class
					.getResourceAsStream("/initial.properties"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return prop;
	}

	public static String getDzfpsl() {
		Properties prop = PropertiesLoad.getProperties();
		return prop.getProperty("fp.sl");
	}

	public static String getdownladPDFURL() {
		Properties prop = PropertiesLoad.getProperties();
		return prop.getProperty("fp.downloadPDF");
	}

	public static String getKpr() {
		if (kprUTF8 == null) {
			Properties prop = PropertiesLoad.getProperties();
			try {
				kprUTF8 = new String(prop.getProperty("fp.kpr").getBytes(
						"ISO-8859-1"), "UTF-8");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		return kprUTF8;
	}

	public static String getSkfwUrl() {
		Properties prop = PropertiesLoad.getProperties();
		return prop.getProperty("skfwUrl");
	}

	public static String getPropertyByName(String name) {
		Properties prop = PropertiesLoad.getProperties();
		return prop.getProperty(name);
	}

	public static String getChckUrl() {
		Properties prop = PropertiesLoad.getProperties();
		return prop.getProperty("fp.chckUrl");
	}

	public static String getdyfpUrl() {
		Properties prop = PropertiesLoad.getProperties();
		return prop.getProperty("fp.dyfpUrl");
	}

	public static String getSendEMailUrl() {
		Properties prop = PropertiesLoad.getProperties();
		return prop.getProperty("fp.sendEMailUrl");
	}

	public static String getTokenUrl() {
		Properties prop = PropertiesLoad.getProperties();
		return prop.getProperty("wx.getTokenUrl");
	}

	public static String getTraRecordWsiteURL() {
		Properties prop = PropertiesLoad.getProperties();
		return formatURL(prop.getProperty("tra.RecordWsiteURL"));
	}

	public static String getDzfpkpUrl() {
		Properties prop = PropertiesLoad.getProperties();
		return formatURL(prop.getProperty("fp.dzfpkpUrl"));
	}

	private static String formatURL(String url) {
		if (url != null && !url.endsWith("/")) {
			url += "/";
		}
		return url;
	}

}
